//引入样式
require("../../assets/css/common.css");
require("../../assets/font_44fp3ls0tzq/iconfont.css");
require("../../assets/css/reset.css");
require("../../assets/css/normalize.css");
require("./sports_drill_list.less");
//引入模块
const dom = require("../../utils/dom.js");
const axios = require("../../utils/axios.js");

document.addEventListener("DOMContentLoaded", function () {
	//获取传输过来的id
	let id = location.search.split("=").pop();

	//返回到上一页
	dom.get("#jiantou").addEventListener("click", function () {
		history.back();
	});

	// axios.get("/api/train/courseDetail?id=" + id).then((res) => {
	// 	//存储数据到本地存储
	// 	let data = res.data.data.fragments;
	// 	localStorage.setItem("fragments", JSON.stringify(data));
	// 	console.log(res.data);
	// 	console.log(data);
	// 	// dom.get("#video img").src = axios.defaults.baseURL + data[0].imgUrl;
	// });
	// let fragments = JSON.parse(localStorage.getItem("fragments"));
	// let n = id - 1;
	// dom.get("#video img").src = axios.defaults.baseURL + fragments[n].imgUrl;
	// console.log(fragments[n].imgUrl);

	axios.get("/api/train/courseList").then((res) => {
		console.log(res.data.data);
		let n = id - 1;
		let data = res.data.data;
		dom.get("#video img").src = axios.defaults.baseURL + data[n].imgurl;
		dom.get("#detail h1").textContent = data[n].name;
		dom.get("#calorie").textContent = data[n].calorie;
		dom.get("#time").textContent = data[n].time;
		dom.get("#detail a").textContent = data[n].peoplenum + "人观看";
		dom.get("#text").textContent = data[n].desc;
		dom.get("#week").textContent = "每周" + data[n].frequency + "次";
		dom.get("#none").textContent = data[n].instrument;
	});
});
